{% extends "layout.html" %}

{% block content %}
    <div class="container">
    <ol class="breadcrumb">
        <li><a href="/">首页</a></li>
        <li class="active">用户中心</li>
        <li class="active">银行账号</li>
    </ol>

    <div class="row">
        <div class="table-responsive col-lg-8 col-md-12">
            {# 表单 #}
            <form class="form-horizontal" method="post" action="">
                {{ form.csrf_token }}
                {# 标签导航 #}
                <ul class="nav nav-tabs">  {# 填充整个导航条：nav-justified #}
                    <li role="presentation"><a href="{{ url_for('user.auth') }}">登录信息</a></li>
                    <li role="presentation" class="active"><a class="selected" href="{{ url_for('user.bank') }}">银行信息</a></li>
                    <li role="presentation"><a href="{{ url_for('user.profile') }}">基本信息</a></li>
                </ul>
                <div class="form-group"></div>
                <div class="form-group{% if form.account_name.errors %} has-error{% endif %}">
                    {{ form.account_name.label(class="col-sm-2 control-label") }}
                    <div class="col-sm-10">
                        {{ form.account_name(class="form-control", placeholder="账户姓名") }}
                        {% for error in form.account_name.errors %}
                            <span class="help-block">{{ error }}</span>
                        {% endfor %}
                    </div>
                </div>
                <div class="form-group{% if form.bank_name.errors %} has-error{% endif %}">
                    {{ form.bank_name.label(class="col-sm-2 control-label") }}
                    <div class="col-sm-10">
                        {{ form.bank_name(class="form-control", placeholder="银行名称") }}
                        {% for error in form.bank_name.errors %}
                            <span class="help-block">{{ error }}</span>
                        {% endfor %}
                    </div>
                </div>
                <div class="form-group{% if form.bank_address.errors %} has-error{% endif %}">
                    {{ form.bank_address.label(class="col-sm-2 control-label") }}
                    <div class="col-sm-10">
                        {{ form.bank_address(class="form-control", placeholder="支行名称") }}
                        {% for error in form.bank_address.errors %}
                            <span class="help-block">{{ error }}</span>
                        {% endfor %}
                    </div>
                </div>
                <div class="form-group{% if form.bank_account.errors %} has-error{% endif %}">
                    {{ form.bank_account.label(class="col-sm-2 control-label") }}
                    <div class="col-sm-10">
                        {{ form.bank_account(class="form-control", placeholder="银行卡号") }}
                        {% for error in form.bank_account.errors %}
                            <span class="help-block">{{ error }}</span>
                        {% endfor %}
                    </div>
                </div>
                <div class="form-group{% if form.status_verified.errors %} has-error{% endif %}">
                    {{ form.status_verified.label(class="col-sm-2 control-label") }}
                    <div class="col-sm-10">
                        {{ form.status_verified(disabled="disabled") }}
                        {% for error in form.status_verified.errors %}
                            <span class="help-block">{{ error }}</span>
                        {% endfor %}
                    </div>
                </div>
                <div class="form-group{% if form.create_time.errors %} has-error{% endif %}">
                    {{ form.create_time.label(class="col-sm-2 control-label") }}
                    <div class="col-sm-10">
                        <div class="form-control">
                            {{ moment(form.create_time.data).format('YYYY-MM-DD HH:mm:ss') }}
                        </div>
                        {% for error in form.create_time.errors %}
                            <span class="help-block">{{ error }}</span>
                        {% endfor %}
                    </div>
                </div>
                <div class="form-group{% if form.update_time.errors %} has-error{% endif %}">
                    {{ form.update_time.label(class="col-sm-2 control-label") }}
                    <div class="col-sm-10">
                        <div class="form-control">
                            {{ moment(form.update_time.data).format('YYYY-MM-DD HH:mm:ss') }}
                        </div>
                        {% for error in form.update_time.errors %}
                            <span class="help-block">{{ error }}</span>
                        {% endfor %}
                    </div>
                </div>
                <div class="form-group">
                    <div class="col-sm-offset-2 col-sm-10">
                        <button type="submit" class="btn btn-success btn-load" data-loading-text="保存中">保存</button>
                        <button type="reset" class="btn btn-default">重新填写</button>
                    </div>
                </div>
            </form>
        </div>
        <!-- 用户概要 -->
        <div class="col-lg-4 col-md-12">
            <!-- 状态信息 -->
            {% include('user/_status.html') %}
            <!-- 推广链接 -->
            {% include('user/_invite_link.html') %}
            <!-- 账户信息 -->
            {% include('user/_account_info.html') %}
            <!-- 我的团队 -->
            {% include('user/_team_tree.html') %}
        </div>
    </div>


    </div>

{% endblock %}

{% block extra_js %}
<script src="{{ url_for('static', filename='plugin/clipboard.js-1.6.1/dist/clipboard.min.js') }}"></script>
<script>
    /**
     * 用户自己激活
     * @returns {boolean}
     */
    function self_active() {
        // console.log($(form).serialize());
        $.ajax({
            url: "{{ url_for('user.ajax_self_active') }}",
            type: 'GET',
            dataType: 'json',
            success: function (result) {
                // console.log(result);
                if(result.hasOwnProperty('error')){
                    alert(result.error);
                }else {
                    alert(result.success);
                    document.location.reload();
                }
            }
        });
        return false;
    }
</script>
<script>
    //推广链接复制
    var clipboard = new Clipboard('.btn');

    clipboard.on('success', function(e) {
        // console.info('Action:', e.action);
        // console.info('Text:', e.text);
        // console.info('Trigger:', e.trigger);
        e.clearSelection();
        alert('复制成功，粘贴使用推广链接');
    });

    clipboard.on('error', function(e) {
        // console.error('Action:', e.action);
        // console.error('Trigger:', e.trigger);
        alert('操作失败，重新复制推广链接');
    });
</script>
{% endblock %}
